package Basics;

import java.util.Random;
import java.util.Scanner;

class guess{
    private int max;
    public guess(){}
    public guess(int max){
        this.max = max;
    }
    public void setMax(int max ){
        this.max = max;
        System.out.println("修改成功");
    }
    public void began(){
        Scanner sc = new Scanner(System.in);
        Random r = new Random();
        int number = r.nextInt(max);
        System.out.print("猜一猜：");
        while(true){
            int guessNumber =  sc.nextInt();
            if(guessNumber == number){
                System.out.println("你猜对了");
                break;
            }else if(guessNumber > number){
                System.out.println("数字大了");
            }else if(guessNumber < number){
                System.out.println("数字小了");
            }else{
                System.out.println("请输入数字");
            }
        }
    }
}

public class Random类 {
    public static void main(String[] args) {
        guess g = new guess(90);
        g.setMax(100);
        g.began();

    }
}
